/**
* @namespace
* A common manager of messages meant to be displayed to the user.  This is a middleman class between
* code that generate messages for users to see and the ui widgets and other classes that deal with 
* the messages and possibly show them to the user in some way.
* @Depends ksg.base.ui.js
*/
ksg.ui.messenger = {
	/**
	* @namespace 
	* Each message to be displayed should be associated with a level to help determine how it
	* will be displayed to the user.
	* @meta-type enum
	*/
	levels: {
		/** */
		normal: 0,
		/** */
		warning: 1,
		/** */
		error: 2
	},
	_observers: [],
	
	/**
	* Observers are notified when a client calls a method to display a message or article.
	* Objservers are typically UI widgets that will decide if they should display the message to the 
	* user based on the level of the message.
	*/
	addObserver: function(observer) {
		this._observers.push(observer);
	},
	
	/**
	* Will trigger an event that a message was received.
	* @param {ksg.ui.messenger.levels} level The criticalness of the message being displayed.	
	*/
	displayMessage: function(level, text) {
		var msg = new ksg.ui.Message(level, text);
		for(var i in this._observers)
			this._observers[i](msg);
	},
	/**
	* @param {ksg.ui.messenger.levels} level The criticalness of the article being displayed.
	* @param {Map} replacements A map of values to use as macros to replace within the context of the message.
	*/
	displayArticle: function(level, text, replacements) {
	}	
};

/**
* @class
* Holds a message created by the user, and is sent to observers of the ksg.ui.messenger
* object when requested to display a message.
* @param {ksg.ui.messenger.levels} level The criticalness of the message.	
*/
ksg.ui.Message = function(level, text) {
	this.level = level;
	this.text = text;
}
